/******************************************************************************
*	testAppMain.c
*
*	coypright (C) 2009 Ding Lixing
*
******************************************************************************/
#include "vm.h"
#include "cm.h"
#include "uart.h"
#include "test.h"

static void startHwInit(void)
{
    vmINFO vm;
    
    vmInfoQuery(&vm);
    uartInit(vm.auxClk);

    uartPrintStr("startMain: Hello World!\r\n");
    uartPrintStr("********************************************\r\n");
    uartPrintStr("Name: "); uartPrintStr(vm.name);
    uartPrintStr(" Version: "); uartPrintHex(vm.version);
    uartPrintNL();
    uartPrintStr("Main clock : "); uartPrintHex(vm.mainClk);
    uartPrintStr("Aux clock : "); uartPrintHex(vm.auxClk);
    uartPrintNL();
    uartPrintStr("********************************************\r\n");
    return;
}

void startMain(void)
{
    unsigned char ch;
    startHwInit();
    cmTaskLibInit();

    vmIntUnlock(VM_IRQ_LOCK_KEY);

    uartPrintStr("Please select test: 1, 2, ...\r\n");

    while(1){
        if(uartRecvByte(&ch) == 0){
            if(ch == '1'){
                //test1();
                break;
            }else if(ch == '2'){
                test2();
                break;
            }else{
                uartPrintStr("Please select test: 1, 2\r\n");
            }
        }
    }

    for(;;){
        /* idle loop here */
    }
}

